<?php

//自动加载类
class CLoad {
	
	//配置核心文件需要加载的类
	public static $coreClass = array(
		"CBase"			=> "core/CBase.class.php",
		"CRequest"		=> "core/CRequest.class.php",
		"CModel"		=> "core/CModel.class.php",
		"CController"   => "core/CController.class.php",
		"CView"			=> "core/CView.class.php",
		"CApp"			=> "core/CApp.class.php",
		"CDb"			=> "core/CDb.class.php",
		"CDb_mysql"		=> "core/db/CDb_mysql.class.php",
		"CDb_pdo"		=> "core/db/CDb_pdo.class.php",
		"Session"		=> "lib/session.class.php",
		"Http"			=> "lib/http.class.php"
	);
	
	//自动加载
	public static function index($class) {
		if(isset(self::$coreClass[$class])) {
		
			CFrame::loadFile(CPATH_FRAME."/".self::$coreClass[$class]);			
		
		} else if(substr($class,-10) =="Controller") {
			
			if(is_file(CPATH_CONTROLLER . "/".$class.".class.php")) {
				CFrame::loadFile(CPATH_CONTROLLER . "/".$class.".class.php");
			}

		} else if(substr($class,-5) == "Model") {
			if(is_file(CPATH_MODEL . '/'.$class.'.class.php')) {
				CFrame::loadFile(CPATH_MODEL . '/'.$class.'.class.php');
			}
		}
	}
}